home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / STUTTGART / UNIXTOOL / GNU / PERL / PERL5SRC.ZIP / !Perl / h / perl < prev    next >
Text File  |  1995-06-30  |  40KB  |  1,594 lines

  1. /*    perl.h
  2.  *
  3.  *    Copyright (c) 1987-1994, Larry Wall
  4.  *
  5.  *    You may distribute under the terms of either the GNU General Public
  6.  *    License or the Artistic License, as specified in the README file.
  7.  *
  8.  */
  9. #ifndef H_PERL
  10. #define H_PERL 1
  11. #define OVERLOAD
  12.  
  13. #undef MSDOS
  14. #undef VMS
  15.  
  16. #include "embed.h"
  17.  
  18. #define VOIDUSED 1
  19. #include "config.h"
  20.  
  21. #ifndef BYTEORDER
  22. #   define BYTEORDER 0x1234
  23. #endif
  24.  
  25. /* Overall memory policy? */
  26. #ifndef CONSERVATIVE
  27. #   define LIBERAL 1
  28. #endif
  29.  
  30.  
  31. /*
  32.  * The following contortions are brought to you on behalf of all the
  33.  * standards, semi-standards, de facto standards, not-so-de-facto standards
  34.  * of the world, as well as all the other botches anyone ever thought of.
  35.  * The basic theory is that if we work hard enough here, the rest of the
  36.  * code can be a lot prettier.  Well, so much for theory.  Sorry, Henry...
  37.  */
  38.  
  39. #ifdef MYMALLOC
  40. #   ifdef HIDEMYMALLOC
  41. #    define malloc Mymalloc
  42. #    define realloc Myremalloc
  43. #    define free Myfree
  44. #   endif
  45. #   define safemalloc malloc
  46. #   define saferealloc realloc
  47. #   define safefree free
  48. #endif
  49.  
  50. /* work around some libPW problems */
  51. #ifdef DOINIT
  52. EXT char Error[1];
  53. #endif
  54.  
  55. /* define this once if either system, instead of cluttering up the src */
  56. #if defined(MSDOS) || defined(atarist)
  57. #define DOSISH 1
  58. #endif
  59.  
  60. #if defined(__STDC__) || defined(vax11c) || defined(_AIX) || defined(__stdc__) || defined(__cplusplus)
  61. # define STANDARD_C 1
  62. #endif
  63.  
  64. #if defined(HASVOLATILE) || defined(STANDARD_C)
  65. #   ifdef __cplusplus
  66. #    define VOL        // to temporarily suppress warnings
  67. #   else
  68. #    define VOL volatile
  69. #   endif
  70. #else
  71. #   define VOL
  72. #endif
  73.  
  74. #define TAINT_IF(c)    (tainted |= (c))
  75. #define TAINT_NOT    (tainted = 0)
  76. #define TAINT_PROPER(s)    if (tainting) taint_proper(no_security, s)
  77. #define TAINT_ENV()    if (tainting) taint_env()
  78.  
  79. #ifdef HAS_GETPGRP2
  80. #   ifndef HAS_GETPGRP
  81. #    define HAS_GETPGRP
  82. #   endif
  83. #endif
  84.  
  85. #ifdef HAS_SETPGRP2
  86. #   ifndef HAS_SETPGRP
  87. #    define HAS_SETPGRP
  88. #   endif
  89. #endif
  90.  
  91. #include <stdio.h>
  92. #ifdef USE_NEXT_CTYPE
  93. #include <appkit/NXCType.h>
  94. #else
  95. #include <ctype.h>
  96. #endif
  97.  
  98. #ifdef RISCOS
  99. #include "fcrypt.h"
  100. #define FCRYPT
  101. #define my_popen popen
  102. #define my_pclose pclose
  103. #define fopen my_fopen
  104. extern FILE *my_fopen(char *,char *);
  105. /* Copied from UnixLib To keep compiler happy just now */
  106. #define O_RDONLY    0
  107. #define O_WRONLY    1
  108. #define O_RDWR        2
  109. #define O_APPEND    0000004
  110. #define O_CREAT     0000010
  111.  
  112. #endif
  113.  
  114. #ifdef METHOD     /* Defined by OSF/1 v3.0 by ctype.h */
  115. #undef METHOD
  116. #endif
  117.  
  118. #include <setjmp.h>
  119.  
  120. #ifdef I_SYS_PARAM
  121. #   ifdef PARAM_NEEDS_TYPES
  122. #    include <sys/types.h>
  123. #   endif
  124. #   include <sys/param.h>
  125. #endif
  126.  
  127.  
  128. /* Use all the "standard" definitions? */
  129. #if defined(STANDARD_C) && defined(I_STDLIB)
  130. #   include <stdlib.h>
  131. #endif /* STANDARD_C */
  132.  
  133. #define MEM_SIZE Size_t
  134.  
  135. #if defined(I_STRING) || defined(__cplusplus)
  136. #   include <string.h>
  137. #else
  138. #   include <strings.h>
  139. #endif
  140.  
  141. #if !defined(HAS_STRCHR) && defined(HAS_INDEX) && !defined(strchr)
  142. #define strchr index
  143. #define strrchr rindex
  144. #endif
  145.  
  146. #if defined(mips) && defined(ultrix) && !defined(__STDC__)
  147. #   undef HAS_MEMCMP
  148. #endif
  149.  
  150. #ifdef HAS_MEMCPY
  151. #  if !defined(STANDARD_C) && !defined(I_STRING) && !defined(I_MEMORY)
  152. #    ifndef memcpy
  153.         extern char * memcpy _((char*, char*, int));
  154. #    endif
  155. #  endif
  156. #else
  157. #   ifndef memcpy
  158. #    ifdef HAS_BCOPY
  159. #        define memcpy(d,s,l) bcopy(s,d,l)
  160. #    else
  161. #        define memcpy(d,s,l) my_bcopy(s,d,l)
  162. #    endif
  163. #   endif
  164. #endif /* HAS_MEMCPY */
  165.  
  166. #ifdef HAS_MEMSET
  167. #  if !defined(STANDARD_C) && !defined(I_STRING) && !defined(I_MEMORY)
  168. #    ifndef memset
  169.     extern char *memset _((char*, int, int));
  170. #    endif
  171. #  endif
  172. #  define memzero(d,l) memset(d,0,l)
  173. #else
  174. #   ifndef memzero
  175. #    ifdef HAS_BZERO
  176. #        define memzero(d,l) bzero(d,l)
  177. #    else
  178. #        define memzero(d,l) my_bzero(d,l)
  179. #    endif
  180. #   endif
  181. #endif /* HAS_MEMSET */
  182.  
  183. #ifdef HAS_MEMCMP
  184. #  if !defined(STANDARD_C) && !defined(I_STRING) && !defined(I_MEMORY)
  185. #    ifndef memcmp
  186.     extern int memcmp _((char*, char*, int));
  187. #    endif
  188. #  endif
  189. #else
  190. #   ifndef memcmp
  191. #    define memcmp     my_memcmp
  192. #   endif
  193. #endif /* HAS_MEMCMP */
  194.  
  195. /* we prefer bcmp slightly for comparisons that don't care about ordering */
  196. #ifndef HAS_BCMP
  197. #   ifndef bcmp
  198. #    define bcmp(s1,s2,l) memcmp(s1,s2,l)
  199. #   endif
  200. #endif /* HAS_BCMP */
  201.  
  202. #if !defined(HAS_MEMMOVE) && !defined(memmove)
  203. #   if defined(HAS_BCOPY) && defined(HAS_SAFE_BCOPY)
  204. #    define memmove(d,s,l) bcopy(s,d,l)
  205. #   else
  206. #    if defined(HAS_MEMCPY) && defined(HAS_SAFE_MEMCPY)
  207. #        define memmove(d,s,l) memcpy(d,s,l)
  208. #    else
  209. #        define memmove(d,s,l) my_bcopy(s,d,l)
  210. #    endif
  211. #   endif
  212. #endif
  213.  
  214. #ifndef RISCOS
  215. #ifndef _TYPES_        /* If types.h defines this it's easy. */
  216. #   ifndef major        /* Does everyone's types.h define this? */
  217. #    include <sys/types.h>
  218. #   endif
  219. #endif
  220. #endif
  221.  
  222. #ifdef I_NETINET_IN
  223. #   include <netinet/in.h>
  224. #endif
  225.  
  226. #ifdef I_SYS_STAT
  227. #include <sys/stat.h>
  228. #endif
  229.  
  230. /* The stat macros for Amdahl UTS, Unisoft System V/88 (and derivatives
  231.    like UTekV) are broken, sometimes giving false positives.  Undefine
  232.    them here and let the code below set them to proper values.
  233.  
  234.    The ghs macro stands for GreenHills Software C-1.8.5 which
  235.    is the C compiler for sysV88 and the various derivatives.
  236.    This header file bug is corrected in gcc-2.5.8 and later versions.
  237.    --Kaveh Ghazi (ghazi@noc.rutgers.edu) 10/3/94.  */
  238.  
  239. #if defined(uts) || (defined(m88k) && defined(ghs))
  240. #   undef S_ISDIR
  241. #   undef S_ISCHR
  242. #   undef S_ISBLK
  243. #   undef S_ISREG
  244. #   undef S_ISFIFO
  245. #   undef S_ISLNK
  246. #endif
  247.  
  248. #ifdef I_TIME
  249. #   include <time.h>
  250. #endif
  251.  
  252. #ifdef I_SYS_TIME
  253. #   ifdef I_SYS_TIME_KERNEL
  254. #    define KERNEL
  255. #   endif
  256. #   include <sys/time.h>
  257. #   ifdef I_SYS_TIME_KERNEL
  258. #    undef KERNEL
  259. #   endif
  260. #endif
  261.  
  262. #ifndef MSDOS
  263. #  if defined(HAS_TIMES) && defined(I_SYS_TIMES)
  264. #    include <sys/times.h>
  265. #  endif
  266. #endif
  267.  
  268. #if defined(HAS_STRERROR) && (!defined(HAS_MKDIR) || !defined(HAS_RMDIR))
  269. #   undef HAS_STRERROR
  270. #endif
  271.  
  272. #ifndef HAS_MKFIFO
  273. #  ifndef mkfifo
  274. #    define mkfifo(path, mode) (mknod((path), (mode) | S_IFIFO, 0))
  275. #  endif
  276. #endif /* !HAS_MKFIFO */
  277.  
  278. #include <errno.h>
  279. #ifdef HAS_SOCKET
  280. #   ifdef I_NET_ERRNO
  281. #     include <net/errno.h>
  282. #   endif
  283. #endif
  284. #ifndef VMS
  285. #   define FIXSTATUS(sts)  (U_L((sts) & 0xffff))
  286. #   define SHIFTSTATUS(sts) ((sts) >> 8)
  287. #   define SETERRNO(errcode,vmserrcode) errno = (errcode)
  288. #else
  289. #   define FIXSTATUS(sts)  (U_L(sts))
  290. #   define SHIFTSTATUS(sts) (sts)
  291. #   define SETERRNO(errcode,vmserrcode) {set_errno(errcode); set_vaxc_errno(vmserrcode);}
  292. #endif
  293.  
  294. #ifndef MSDOS
  295. #   ifndef errno
  296.     extern int errno;     /* ANSI allows errno to be an lvalue expr */
  297. #   endif
  298. #endif
  299.  
  300. #ifdef HAS_STRERROR
  301. #       ifdef VMS
  302.     char *strerror _((int,...));
  303. #       else
  304.     char *strerror _((int));
  305. #       endif
  306. #       ifndef Strerror
  307. #           define Strerror strerror
  308. #       endif
  309. #else
  310. #    ifdef HAS_SYS_ERRLIST
  311.     extern int sys_nerr;
  312.     extern char *sys_errlist[];
  313. #       ifndef Strerror
  314. #           define Strerror(e) \
  315.         ((e) < 0 || (e) >= sys_nerr ? "(unknown)" : sys_errlist[e])
  316. #       endif
  317. #   endif
  318. #endif
  319.  
  320. #ifdef I_SYS_IOCTL
  321. #   ifndef _IOCTL_
  322. #    include <sys/ioctl.h>
  323. #   endif
  324. #endif
  325.  
  326. #if defined(mc300) || defined(mc500) || defined(mc700) || defined(mc6000)
  327. #   ifdef HAS_SOCKETPAIR
  328. #    undef HAS_SOCKETPAIR
  329. #   endif
  330. #   ifdef I_NDBM
  331. #    undef I_NDBM
  332. #   endif
  333. #endif
  334.  
  335. #if INTSIZE == 2
  336. #   define htoni htons
  337. #   define ntohi ntohs
  338. #else
  339. #   define htoni htonl
  340. #   define ntohi ntohl
  341. #endif
  342.  
  343. /* Configure already sets Direntry_t */
  344. #if defined(I_DIRENT)
  345. #   include <dirent.h>
  346. #   if defined(NeXT) && defined(I_SYS_DIR) /* NeXT needs dirent + sys/dir.h */
  347. #    include <sys/dir.h>
  348. #   endif
  349. #else
  350. #   ifdef I_SYS_NDIR
  351. #    include <sys/ndir.h>
  352. #   else
  353. #    ifdef I_SYS_DIR
  354. #        ifdef hp9000s500
  355. #        include <ndir.h>    /* may be wrong in the future */
  356. #        else
  357. #        include <sys/dir.h>
  358. #        endif
  359. #    endif
  360. #   endif
  361. #endif
  362.  
  363. #ifdef FPUTS_BOTCH
  364. /* work around botch in SunOS 4.0.1 and 4.0.2 */
  365. #   ifndef fputs
  366. #    define fputs(sv,fp) fprintf(fp,"%s",sv)
  367. #   endif
  368. #endif
  369.  
  370. /*
  371.  * The following gobbledygook brought to you on behalf of __STDC__.
  372.  * (I could just use #ifndef __STDC__, but this is more bulletproof
  373.  * in the face of half-implementations.)
  374.  */
  375.  
  376. #ifndef S_IFMT
  377. #   ifdef _S_IFMT
  378. #    define S_IFMT _S_IFMT
  379. #   else
  380. #    define S_IFMT 0170000
  381. #   endif
  382. #endif
  383.  
  384. #ifndef S_ISDIR
  385. #   define S_ISDIR(m) ((m & S_IFMT) == S_IFDIR)
  386. #endif
  387.  
  388. #ifndef S_ISCHR
  389. #   define S_ISCHR(m) ((m & S_IFMT) == S_IFCHR)
  390. #endif
  391.  
  392. #ifndef S_ISBLK
  393. #   ifdef S_IFBLK
  394. #    define S_ISBLK(m) ((m & S_IFMT) == S_IFBLK)
  395. #   else
  396. #    define S_ISBLK(m) (0)
  397. #   endif
  398. #endif
  399.  
  400. #ifndef S_ISREG
  401. #   define S_ISREG(m) ((m & S_IFMT) == S_IFREG)
  402. #endif
  403.  
  404. #ifndef S_ISFIFO
  405. #   ifdef S_IFIFO
  406. #    define S_ISFIFO(m) ((m & S_IFMT) == S_IFIFO)
  407. #   else
  408. #    define S_ISFIFO(m) (0)
  409. #   endif
  410. #endif
  411.  
  412. #ifndef S_ISLNK
  413. #   ifdef _S_ISLNK
  414. #    define S_ISLNK(m) _S_ISLNK(m)
  415. #   else
  416. #    ifdef _S_IFLNK
  417. #        define S_ISLNK(m) ((m & S_IFMT) == _S_IFLNK)
  418. #    else
  419. #        ifdef S_IFLNK
  420. #        define S_ISLNK(m) ((m & S_IFMT) == S_IFLNK)
  421. #        else
  422. #        define S_ISLNK(m) (0)
  423. #        endif
  424. #    endif
  425. #   endif
  426. #endif
  427.  
  428. #ifndef S_ISSOCK
  429. #   ifdef _S_ISSOCK
  430. #    define S_ISSOCK(m) _S_ISSOCK(m)
  431. #   else
  432. #    ifdef _S_IFSOCK
  433. #        define S_ISSOCK(m) ((m & S_IFMT) == _S_IFSOCK)
  434. #    else
  435. #        ifdef S_IFSOCK
  436. #        define S_ISSOCK(m) ((m & S_IFMT) == S_IFSOCK)
  437. #        else
  438. #        define S_ISSOCK(m) (0)
  439. #        endif
  440. #    endif
  441. #   endif
  442. #endif
  443.  
  444. #ifndef S_IRUSR
  445. #   ifdef S_IREAD
  446. #    define S_IRUSR S_IREAD
  447. #    define S_IWUSR S_IWRITE
  448. #    define S_IXUSR S_IEXEC
  449. #   else
  450. #    define S_IRUSR 0400
  451. #    define S_IWUSR 0200
  452. #    define S_IXUSR 0100
  453. #   endif
  454. #   define S_IRGRP (S_IRUSR>>3)
  455. #   define S_IWGRP (S_IWUSR>>3)
  456. #   define S_IXGRP (S_IXUSR>>3)
  457. #   define S_IROTH (S_IRUSR>>6)
  458. #   define S_IWOTH (S_IWUSR>>6)
  459. #   define S_IXOTH (S_IXUSR>>6)
  460. #endif
  461.  
  462. #ifndef S_ISUID
  463. #   define S_ISUID 04000
  464. #endif
  465.  
  466. #ifndef S_ISGID
  467. #   define S_ISGID 02000
  468. #endif
  469.  
  470. #ifdef ff_next
  471. #   undef ff_next
  472. #endif
  473.  
  474. #if defined(cray) || defined(gould) || defined(i860) || defined(pyr)
  475. #   define SLOPPYDIVIDE
  476. #endif
  477.  
  478. #if defined(cray) || defined(convex) || defined (uts) || BYTEORDER > 0xffff
  479. #   define HAS_QUAD
  480. #endif
  481.  
  482. #ifdef UV
  483. #undef UV
  484. #endif
  485.  
  486. #ifdef HAS_QUAD
  487. #   ifdef cray
  488. #    define Quad_t int
  489. #   else
  490. #    if defined(convex) || defined (uts)
  491. #        define Quad_t long long
  492. #    else
  493. #        define Quad_t long
  494. #    endif
  495. #   endif
  496.     typedef Quad_t IV;
  497.     typedef unsigned Quad_t UV;
  498. #else
  499.     typedef long IV;
  500.     typedef unsigned long UV;
  501. #endif
  502.  
  503. typedef MEM_SIZE STRLEN;
  504.  
  505. typedef struct op OP;
  506. typedef struct cop COP;
  507. typedef struct unop UNOP;
  508. typedef struct binop BINOP;
  509. typedef struct listop LISTOP;
  510. typedef struct logop LOGOP;
  511. typedef struct condop CONDOP;
  512. typedef struct pmop PMOP;
  513. typedef struct svop SVOP;
  514. typedef struct gvop GVOP;
  515. typedef struct pvop PVOP;
  516. typedef struct cvop CVOP;
  517. typedef struct loop LOOP;
  518.  
  519. typedef struct Outrec Outrec;
  520. typedef struct interpreter PerlInterpreter;
  521. typedef struct ff FF;
  522. typedef struct sv SV;
  523. typedef struct av AV;
  524. typedef struct hv HV;
  525. typedef struct cv CV;
  526. typedef struct regexp REGEXP;
  527. typedef struct gp GP;
  528. typedef struct sv GV;
  529. typedef struct io IO;
  530. typedef struct context CONTEXT;
  531. typedef struct block BLOCK;
  532.  
  533. typedef struct magic MAGIC;
  534. typedef struct xrv XRV;
  535. typedef struct xpv XPV;
  536. typedef struct xpviv XPVIV;
  537. typedef struct xpvnv XPVNV;
  538. typedef struct xpvmg XPVMG;
  539. typedef struct xpvlv XPVLV;
  540. typedef struct xpvav XPVAV;
  541. typedef struct xpvhv XPVHV;
  542. typedef struct xpvgv XPVGV;
  543. typedef struct xpvcv XPVCV;
  544. typedef struct xpvbm XPVBM;
  545. typedef struct xpvfm XPVFM;
  546. typedef struct xpvio XPVIO;
  547. typedef struct mgvtbl MGVTBL;
  548. typedef union any ANY;
  549.  
  550. typedef int (*cryptswitch_t) _((void));
  551.  
  552. #include "handy.h"
  553.  
  554. #ifdef DOSISH
  555. #   include "dosish.h"
  556. #else
  557. # if defined(VMS)
  558. #   include "vmsish.h"
  559. # else
  560. #   include "unixish.h"
  561. # endif
  562. #endif
  563.  
  564. #ifndef HAS_PAUSE
  565. #define pause() sleep((32767<<16)+32767)
  566. #endif
  567.  
  568. #ifndef IOCPARM_LEN
  569. #   ifdef IOCPARM_MASK
  570.     /* on BSDish systes we're safe */
  571. #    define IOCPARM_LEN(x)  (((x) >> 16) & IOCPARM_MASK)
  572. #   else
  573.     /* otherwise guess at what's safe */
  574. #    define IOCPARM_LEN(x)    256
  575. #   endif
  576. #endif
  577.  
  578. union any {
  579.     void*    any_ptr;
  580.     I32        any_i32;
  581.     IV        any_iv;
  582.     long    any_long;
  583.     void    (*any_dptr) _((void*));
  584. };
  585.  
  586. #include "regexp.h"
  587. #include "sv.h"
  588. #include "util.h"
  589. #include "form.h"
  590. #include "gv.h"
  591. #include "cv.h"
  592. #include "opcode.h"
  593. #include "op.h"
  594. #include "cop.h"
  595. #include "av.h"
  596. #include "hv.h"
  597. #include "mg.h"
  598. #include "scope.h"
  599.  
  600. #if defined(iAPX286) || defined(M_I286) || defined(I80286)
  601. #   define I286
  602. #endif
  603.  
  604. #if defined(htonl) && !defined(HAS_HTONL)
  605. #define HAS_HTONL
  606. #endif
  607. #if defined(htons) && !defined(HAS_HTONS)
  608. #define HAS_HTONS
  609. #endif
  610. #if defined(ntohl) && !defined(HAS_NTOHL)
  611. #define HAS_NTOHL
  612. #endif
  613. #if defined(ntohs) && !defined(HAS_NTOHS)
  614. #define HAS_NTOHS
  615. #endif
  616. #ifndef HAS_HTONL
  617. #if (BYTEORDER & 0xffff) != 0x4321
  618. #define HAS_HTONS
  619. #define HAS_HTONL
  620. #define HAS_NTOHS
  621. #define HAS_NTOHL
  622. #define MYSWAP
  623. #define htons my_swap
  624. #define htonl my_htonl
  625. #define ntohs my_swap
  626. #define ntohl my_ntohl
  627. #endif
  628. #else
  629. #if (BYTEORDER & 0xffff) == 0x4321
  630. #undef HAS_HTONS
  631. #undef HAS_HTONL
  632. #undef HAS_NTOHS
  633. #undef HAS_NTOHL
  634. #endif
  635. #endif
  636.  
  637. /*
  638.  * Little-endian byte order functions - 'v' for 'VAX', or 'reVerse'.
  639.  * -DWS
  640.  */
  641. #if BYTEORDER != 0x1234
  642. # define HAS_VTOHL
  643. # define HAS_VTOHS
  644. # define HAS_HTOVL
  645. # define HAS_HTOVS
  646. # if BYTEORDER == 0x4321
  647. #  define vtohl(x)    ((((x)&0xFF)<<24)    \
  648.             +(((x)>>24)&0xFF)    \
  649.             +(((x)&0x0000FF00)<<8)    \
  650.             +(((x)&0x00FF0000)>>8)    )
  651. #  define vtohs(x)    ((((x)&0xFF)<<8) + (((x)>>8)&0xFF))
  652. #  define htovl(x)    vtohl(x)
  653. #  define htovs(x)    vtohs(x)
  654. # endif
  655.     /* otherwise default to functions in util.c */
  656. #endif
  657.  
  658. #ifdef CASTNEGFLOAT
  659. #define U_S(what) ((U16)(what))
  660. #define U_I(what) ((unsigned int)(what))
  661. #define U_L(what) ((U32)(what))
  662. #else
  663. U32 cast_ulong _((double));
  664. #define U_S(what) ((U16)cast_ulong(what))
  665. #define U_I(what) ((unsigned int)cast_ulong(what))
  666. #define U_L(what) (cast_ulong(what))
  667. #endif
  668.  
  669. #ifdef CASTI32
  670. #define I_32(what) ((I32)(what))
  671. #define I_V(what) ((IV)(what))
  672. #else
  673. I32 cast_i32 _((double));
  674. #define I_32(what) (cast_i32(what))
  675. IV cast_iv _((double));
  676. #define I_V(what) (cast_iv(what))
  677. #endif
  678.  
  679. struct Outrec {
  680.     I32        o_lines;
  681.     char    *o_str;
  682.     U32        o_len;
  683. };
  684.  
  685. #ifndef MAXSYSFD
  686. #   define MAXSYSFD 2
  687. #endif
  688.  
  689. #ifdef DOSISH
  690. #define TMPPATH "plXXXXXX"
  691. #else
  692. #ifdef VMS
  693. #define TMPPATH "sys$scratch:perl-eXXXXXX"
  694. #else
  695. #ifdef RISCOS
  696. #define TMPPATH "<Wimp$ScrapDir>.perltmp"
  697. #else
  698. #define TMPPATH "/tmp/perl-eXXXXXX"
  699. #endif
  700. #endif
  701. #endif
  702.  
  703. #if !defined(__cplusplus) && !defined(RISCOS)
  704. Uid_t getuid _((void));
  705. Uid_t geteuid _((void));
  706. Gid_t getgid _((void));
  707. Gid_t getegid _((void));
  708. #endif
  709.  
  710. #ifdef DEBUGGING
  711. #define YYDEBUG 1
  712. #define DEB(a)                 a
  713. #define DEBUG(a)   if (debug)        a
  714. #define DEBUG_p(a) if (debug & 1)    a
  715. #define DEBUG_s(a) if (debug & 2)    a
  716. #define DEBUG_l(a) if (debug & 4)    a
  717. #define DEBUG_t(a) if (debug & 8)    a
  718. #define DEBUG_o(a) if (debug & 16)    a
  719. #define DEBUG_c(a) if (debug & 32)    a
  720. #define DEBUG_P(a) if (debug & 64)    a
  721. #define DEBUG_m(a) if (debug & 128)    a
  722. #define DEBUG_f(a) if (debug & 256)    a
  723. #define DEBUG_r(a) if (debug & 512)    a
  724. #define DEBUG_x(a) if (debug & 1024)    a
  725. #define DEBUG_u(a) if (debug & 2048)    a
  726. #define DEBUG_L(a) if (debug & 4096)    a
  727. #define DEBUG_H(a) if (debug & 8192)    a
  728. #define DEBUG_X(a) if (debug & 16384)    a
  729. #define DEBUG_D(a) if (debug & 32768)    a
  730. #else
  731. #define DEB(a)
  732. #define DEBUG(a)
  733. #define DEBUG_p(a)
  734. #define DEBUG_s(a)
  735. #define DEBUG_l(a)
  736. #define DEBUG_t(a)
  737. #define DEBUG_o(a)
  738. #define DEBUG_c(a)
  739. #define DEBUG_P(a)
  740. #define DEBUG_m(a)
  741. #define DEBUG_f(a)
  742. #define DEBUG_r(a)
  743. #define DEBUG_x(a)
  744. #define DEBUG_u(a)
  745. #define DEBUG_L(a)
  746. #define DEBUG_H(a)
  747. #define DEBUG_X(a)
  748. #define DEBUG_D(a)
  749. #endif
  750. #define YYMAXDEPTH 300
  751.  
  752. #define assert(what)    DEB( {                        \
  753.     if (!(what)) {                            \
  754.         croak("Assertion failed: file \"%s\", line %d",        \
  755.         __FILE__, __LINE__);                    \
  756.         exit(1);                            \
  757.     }})
  758.  
  759. struct ufuncs {
  760.     I32 (*uf_val)_((IV, SV*));
  761.     I32 (*uf_set)_((IV, SV*));
  762.     IV uf_index;
  763. };
  764.  
  765. /* Fix these up for __STDC__ */
  766. #ifndef __cplusplus
  767. char *mktemp _((char*));
  768. double atof _((const char*));
  769. #endif
  770.  
  771. #ifndef STANDARD_C
  772. /* All of these are in stdlib.h or time.h for ANSI C */
  773. Time_t time();
  774. struct tm *gmtime(), *localtime();
  775. char *strchr(), *strrchr();
  776. char *strcpy(), *strcat();
  777. #endif /* ! STANDARD_C */
  778.  
  779.  
  780. #ifdef I_MATH
  781. #    include <math.h>
  782. #else
  783. #   ifdef __cplusplus
  784.     extern "C" {
  785. #   endif
  786.         double exp _((double));
  787.         double fmod _((double,double));
  788.         double log _((double));
  789.         double sqrt _((double));
  790.         double modf _((double,double*));
  791.         double sin _((double));
  792.         double cos _((double));
  793.         double atan2 _((double,double));
  794.         double pow _((double,double));
  795. #   ifdef __cplusplus
  796.     };
  797. #   endif
  798. #endif
  799.  
  800. #ifndef HAS_FMOD
  801. #   ifdef HAS_DREM
  802. #    define fmod(x,y) drem((x),(y))
  803. #   else
  804. #    define USE_MY_FMOD
  805. #    define fmod(x,y) my_fmod(x,y)
  806. #   endif
  807. #endif
  808.  
  809. #if !defined( __cplusplus) && !defined(RISCOS)
  810. char *crypt _((const char*, const char*));
  811. char *getenv _((const char*));
  812. Off_t lseek _((int,Off_t,int));
  813. char *getlogin _((void));
  814. #endif
  815.  
  816. #ifdef EUNICE
  817. #define UNLINK unlnk
  818. I32 unlnk _((char*));
  819. #else
  820. #define UNLINK unlink
  821. #endif
  822.  
  823. #ifndef HAS_SETREUID
  824. #  ifdef HAS_SETRESUID
  825. #    define setreuid(r,e) setresuid(r,e,(Uid_t)-1)
  826. #    define HAS_SETREUID
  827. #  endif
  828. #endif
  829. #ifndef HAS_SETREGID
  830. #  ifdef HAS_SETRESGID
  831. #    define setregid(r,e) setresgid(r,e,(Gid_t)-1)
  832. #    define HAS_SETREGID
  833. #  endif
  834. #endif
  835.  
  836. #define SCAN_DEF 0
  837. #define SCAN_TR 1
  838. #define SCAN_REPL 2
  839.  
  840. #ifdef DEBUGGING
  841. # ifndef register
  842. #  define register
  843. # endif
  844. # define PAD_SV(po) pad_sv(po)
  845. #else
  846. # define PAD_SV(po) curpad[po]
  847. #endif
  848.  
  849. /****************/
  850. /* Truly global */
  851. /****************/
  852.  
  853. /* global state */
  854. EXT PerlInterpreter *    curinterp;    /* currently running interpreter */
  855. #ifndef VMS  /* VMS doesn't use environ array */
  856. extern char **    environ;    /* environment variables supplied via exec */
  857. #endif
  858. EXT int        uid;        /* current real user id */
  859. EXT int        euid;        /* current effective user id */
  860. EXT int        gid;        /* current real group id */
  861. EXT int        egid;        /* current effective group id */
  862. EXT bool    nomemok;    /* let malloc context handle nomem */
  863. EXT U32        an;        /* malloc sequence number */
  864. EXT U32        cop_seqmax;    /* statement sequence number */
  865. EXT U32        op_seqmax;    /* op sequence number */
  866. EXT U32        evalseq;    /* eval sequence number */
  867. EXT U32        sub_generation;    /* inc to force methods to be looked up again */
  868. EXT char **    origenviron;
  869. EXT U32        origalen;
  870. EXT U32 *    profiledata;
  871.  
  872. EXT XPV*    xiv_arenaroot;    /* list of allocated xiv areas */
  873. EXT IV **    xiv_root;    /* free xiv list--shared by interpreters */
  874. EXT double *    xnv_root;    /* free xnv list--shared by interpreters */
  875. EXT XRV *    xrv_root;    /* free xrv list--shared by interpreters */
  876. EXT XPV *    xpv_root;    /* free xpv list--shared by interpreters */
  877.  
  878. /* Stack for currently executing thread--context switch must handle this.     */
  879. EXT SV **    stack_base;    /* stack->array_ary */
  880. EXT SV **    stack_sp;    /* stack pointer now */
  881. EXT SV **    stack_max;    /* stack->array_ary + stack->array_max */
  882.  
  883. /* likewise for these */
  884.  
  885. EXT OP *    op;        /* current op--oughta be in a global register */
  886.  
  887. EXT I32 *    scopestack;    /* blocks we've entered */
  888. EXT I32        scopestack_ix;
  889. EXT I32        scopestack_max;
  890.  
  891. EXT ANY*    savestack;    /* to save non-local values on */
  892. EXT I32        savestack_ix;
  893. EXT I32        savestack_max;
  894.  
  895. EXT OP **    retstack;    /* returns we've pushed */
  896. EXT I32        retstack_ix;
  897. EXT I32        retstack_max;
  898.  
  899. EXT I32 *    markstack;    /* stackmarks we're remembering */
  900. EXT I32 *    markstack_ptr;    /* stackmarks we're remembering */
  901. EXT I32 *    markstack_max;    /* stackmarks we're remembering */
  902.  
  903. EXT SV **    curpad;
  904.  
  905. /* temp space */
  906. EXT SV *    Sv;
  907. EXT XPV *    Xpv;
  908. EXT char    buf[1024];
  909. EXT char    tokenbuf[256];
  910. EXT struct stat    statbuf;
  911. #ifdef HAS_TIMES
  912. EXT struct tms    timesbuf;
  913. #endif
  914. EXT STRLEN na;        /* for use in SvPV when length is Not Applicable */
  915.  
  916. /* for tmp use in stupid debuggers */
  917. EXT int *    di;
  918. EXT short *    ds;
  919. EXT char *    dc;
  920.  
  921. /* handy constants */
  922. EXT char *    Yes INIT("1");
  923. EXT char *    No INIT("");
  924. EXT char *    hexdigit INIT("0123456789abcdef0123456789ABCDEFx");
  925. EXT char *    patleave INIT("\\.^$@dDwWsSbB+*?|()-nrtfeaxc0123456789[{]}");
  926. EXT char *    vert INIT("|");
  927.  
  928. EXT char    warn_uninit[]
  929.   INIT("Use of uninitialized value");
  930. EXT char    warn_nosemi[]
  931.   INIT("Semicolon seems to be missing");
  932. EXT char    warn_reserved[]
  933.   INIT("Unquoted string \"%s\" may clash with future reserved word");
  934. EXT char    warn_nl[]
  935.   INIT("Unsuccessful %s on filename containing newline");
  936. EXT char    no_wrongref[]
  937.   INIT("Can't use %s ref as %s ref");
  938. EXT char    no_symref[]
  939.   INIT("Can't use string (\"%.32s\") as %s ref while \"strict refs\" in use");
  940. EXT char    no_usym[]
  941.   INIT("Can't use an undefined value as %s reference");
  942. EXT char    no_aelem[]
  943.   INIT("Modification of non-creatable array value attempted, subscript %d");
  944. EXT char    no_helem[]
  945.   INIT("Modification of non-creatable hash value attempted, subscript \"%s\"");
  946. EXT char    no_modify[]
  947.   INIT("Modification of a read-only value attempted");
  948. EXT char    no_mem[]
  949.   INIT("Out of memory!\n");
  950. EXT char    no_security[]
  951.   INIT("Insecure dependency in %s%s");
  952. EXT char    no_sock_func[]
  953.   INIT("Unsupported socket function \"%s\" called");
  954. EXT char    no_dir_func[]
  955.   INIT("Unsupported directory function \"%s\" called");
  956. EXT char    no_func[]
  957.   INIT("The %s function is unimplemented");
  958. EXT char    no_myglob[]
  959.   INIT("\"my\" variable %s can't be in a package");
  960.  
  961. EXT SV        sv_undef;
  962. EXT SV        sv_no;
  963. EXT SV        sv_yes;
  964. #ifdef CSH
  965.     EXT char *    cshname INIT(CSH);
  966.     EXT I32    cshlen;
  967. #endif
  968.  
  969. #ifdef DOINIT
  970. EXT char *sig_name[] = {
  971.     SIG_NAME,0
  972. };
  973. #else
  974. EXT char *sig_name[];
  975. #endif
  976.  
  977. #ifdef DOINIT
  978. EXT unsigned char fold[] = {    /* fast case folding table */
  979.     0,    1,    2,    3,    4,    5,    6,    7,
  980.     8,    9,    10,    11,    12,    13,    14,    15,
  981.     16,    17,    18,    19,    20,    21,    22,    23,
  982.     24,    25,    26,    27,    28,    29,    30,    31,
  983.     32,    33,    34,    35,    36,    37,    38,    39,
  984.     40,    41,    42,    43,    44,    45,    46,    47,
  985.     48,    49,    50,    51,    52,    53,    54,    55,
  986.     56,    57,    58,    59,    60,    61,    62,    63,
  987.     64,    'a',    'b',    'c',    'd',    'e',    'f',    'g',
  988.     'h',    'i',    'j',    'k',    'l',    'm',    'n',    'o',
  989.     'p',    'q',    'r',    's',    't',    'u',    'v',    'w',
  990.     'x',    'y',    'z',    91,    92,    93,    94,    95,
  991.     96,    'A',    'B',    'C',    'D',    'E',    'F',    'G',
  992.     'H',    'I',    'J',    'K',    'L',    'M',    'N',    'O',
  993.     'P',    'Q',    'R',    'S',    'T',    'U',    'V',    'W',
  994.     'X',    'Y',    'Z',    123,    124,    125,    126,    127,
  995.     128,    129,    130,    131,    132,    133,    134,    135,
  996.     136,    137,    138,    139,    140,    141,    142,    143,
  997.     144,    145,    146,    147,    148,    149,    150,    151,
  998.     152,    153,    154,    155,    156,    157,    158,    159,
  999.     160,    161,    162,    163,    164,    165,    166,    167,
  1000.     168,    169,    170,    171,    172,    173,    174,    175,
  1001.     176,    177,    178,    179,    180,    181,    182,    183,
  1002.     184,    185,    186,    187,    188,    189,    190,    191,
  1003.     192,    193,    194,    195,    196,    197,    198,    199,
  1004.     200,    201,    202,    203,    204,    205,    206,    207,
  1005.     208,    209,    210,    211,    212,    213,    214,    215,
  1006.     216,    217,    218,    219,    220,    221,    222,    223,
  1007.     224,    225,    226,    227,    228,    229,    230,    231,
  1008.     232,    233,    234,    235,    236,    237,    238,    239,
  1009.     240,    241,    242,    243,    244,    245,    246,    247,
  1010.     248,    249,    250,    251,    252,    253,    254,    255
  1011. };
  1012. #else
  1013. EXT unsigned char fold[];
  1014. #endif
  1015.  
  1016. #ifdef DOINIT
  1017. EXT unsigned char freq[] = {    /* letter frequencies for mixed English/C */
  1018.     1,    2,    84,    151,    154,    155,    156,    157,
  1019.     165,    246,    250,    3,    158,    7,    18,    29,
  1020.     40,    51,    62,    73,    85,    96,    107,    118,
  1021.     129,    140,    147,    148,    149,    150,    152,    153,
  1022.     255,    182,    224,    205,    174,    176,    180,    217,
  1023.     233,    232,    236,    187,    235,    228,    234,    226,
  1024.     222,    219,    211,    195,    188,    193,    185,    184,
  1025.     191,    183,    201,    229,    181,    220,    194,    162,
  1026.     163,    208,    186,    202,    200,    218,    198,    179,
  1027.     178,    214,    166,    170,    207,    199,    209,    206,
  1028.     204,    160,    212,    216,    215,    192,    175,    173,
  1029.     243,    172,    161,    190,    203,    189,    164,    230,
  1030.     167,    248,    227,    244,    242,    255,    241,    231,
  1031.     240,    253,    169,    210,    245,    237,    249,    247,
  1032.     239,    168,    252,    251,    254,    238,    223,    221,
  1033.     213,    225,    177,    197,    171,    196,    159,    4,
  1034.     5,    6,    8,    9,    10,    11,    12,    13,
  1035.     14,    15,    16,    17,    19,    20,    21,    22,
  1036.     23,    24,    25,    26,    27,    28,    30,    31,
  1037.     32,    33,    34,    35,    36,    37,    38,    39,
  1038.     41,    42,    43,    44,    45,    46,    47,    48,
  1039.     49,    50,    52,    53,    54,    55,    56,    57,
  1040.     58,    59,    60,    61,    63,    64,    65,    66,
  1041.     67,    68,    69,    70,    71,    72,    74,    75,
  1042.     76,    77,    78,    79,    80,    81,    82,    83,
  1043.     86,    87,    88,    89,    90,    91,    92,    93,
  1044.     94,    95,    97,    98,    99,    100,    101,    102,
  1045.     103,    104,    105,    106,    108,    109,    110,    111,
  1046.     112,    113,    114,    115,    116,    117,    119,    120,
  1047.     121,    122,    123,    124,    125,    126,    127,    128,
  1048.     130,    131,    132,    133,    134,    135,    136,    137,
  1049.     138,    139,    141,    142,    143,    144,    145,    146
  1050. };
  1051. #else
  1052. EXT unsigned char freq[];
  1053. #endif
  1054.  
  1055. #ifdef DEBUGGING
  1056. #ifdef DOINIT
  1057. EXT char* block_type[] = {
  1058.     "NULL",
  1059.     "SUB",
  1060.     "EVAL",
  1061.     "LOOP",
  1062.     "SUBST",
  1063.     "BLOCK",
  1064. };
  1065. #else
  1066. EXT char* block_type[];
  1067. #endif
  1068. #endif
  1069.  
  1070. /*****************************************************************************/
  1071. /* This lexer/parser stuff is currently global since yacc is hard to reenter */
  1072. /*****************************************************************************/
  1073. /* XXX This needs to be revisited, since BEGIN makes yacc re-enter... */
  1074.  
  1075. #include "perly.h"
  1076.  
  1077. typedef enum {
  1078.     XOPERATOR,
  1079.     XTERM,
  1080.     XREF,
  1081.     XSTATE,
  1082.     XBLOCK,
  1083.     XTERMBLOCK
  1084. } expectation;
  1085.  
  1086. EXT U32        lex_state;    /* next token is determined */
  1087. EXT U32        lex_defer;    /* state after determined token */
  1088. EXT expectation    lex_expect;    /* expect after determined token */
  1089. EXT I32        lex_brackets;    /* bracket count */
  1090. EXT I32        lex_formbrack;    /* bracket count at outer format level */
  1091. EXT I32        lex_fakebrack;    /* outer bracket is mere delimiter */
  1092. EXT I32        lex_casemods;    /* casemod count */
  1093. EXT I32        lex_dojoin;    /* doing an array interpolation */
  1094. EXT I32        lex_starts;    /* how many interps done on level */
  1095. EXT SV *    lex_stuff;    /* runtime pattern from m// or s/// */
  1096. EXT SV *    lex_repl;    /* runtime replacement from s/// */
  1097. EXT OP *    lex_op;        /* extra info to pass back on op */
  1098. EXT OP *    lex_inpat;    /* in pattern $) and $| are special */
  1099. EXT I32        lex_inwhat;    /* what kind of quoting are we in */
  1100. EXT char *    lex_brackstack;    /* what kind of brackets to pop */
  1101. EXT char *    lex_casestack;    /* what kind of case mods in effect */
  1102.  
  1103. /* What we know when we're in LEX_KNOWNEXT state. */
  1104. EXT YYSTYPE    nextval[5];    /* value of next token, if any */
  1105. EXT I32        nexttype[5];    /* type of next token */
  1106. EXT I32        nexttoke;
  1107.  
  1108. EXT FILE * VOL    rsfp INIT(Nullfp);
  1109. EXT SV *    linestr;
  1110. EXT char *    bufptr;
  1111. EXT char *    oldbufptr;
  1112. EXT char *    oldoldbufptr;
  1113. EXT char *    bufend;
  1114. EXT expectation expect INIT(XSTATE);    /* how to interpret ambiguous tokens */
  1115. EXT char *    autoboot_preamble INIT(Nullch);
  1116. EXT cryptswitch_t cryptswitch_fp;
  1117.  
  1118. EXT I32        multi_start;    /* 1st line of multi-line string */
  1119. EXT I32        multi_end;    /* last line of multi-line string */
  1120. EXT I32        multi_open;    /* delimiter of said string */
  1121. EXT I32        multi_close;    /* delimiter of said string */
  1122.  
  1123. EXT GV *    scrgv;
  1124. EXT I32        error_count;    /* how many errors so far, max 10 */
  1125. EXT I32        subline;    /* line this subroutine began on */
  1126. EXT SV *    subname;    /* name of current subroutine */
  1127.  
  1128. EXT CV *    compcv;        /* currently compiling subroutine */
  1129. EXT AV *    comppad;    /* storage for lexically scoped temporaries */
  1130. EXT AV *    comppad_name;    /* variable names for "my" variables */
  1131. EXT I32        comppad_name_fill;/* last "introduced" variable offset */
  1132. EXT I32        min_intro_pending;/* start of vars to introduce */
  1133. EXT I32        max_intro_pending;/* end of vars to introduce */
  1134. EXT I32        padix;        /* max used index in current "register" pad */
  1135. EXT I32        padix_floor;    /* how low may inner block reset padix */
  1136. EXT I32        pad_reset_pending; /* reset pad on next attempted alloc */
  1137. EXT COP        compiling;
  1138.  
  1139. EXT I32        thisexpr;    /* name id for nothing_in_common() */
  1140. EXT char *    last_uni;    /* position of last named-unary operator */
  1141. EXT char *    last_lop;    /* position of last list operator */
  1142. EXT OPCODE    last_lop_op;    /* last list operator */
  1143. EXT bool    in_my;        /* we're compiling a "my" declaration */
  1144. #ifdef FCRYPT
  1145. EXT I32        cryptseen;    /* has fast crypt() been initialized? */
  1146. #endif
  1147.  
  1148. EXT U32        hints;        /* various compilation flags */
  1149.  
  1150.                 /* Note: the lowest 8 bits are reserved for
  1151.                    stuffing into op->op_private */
  1152. #define HINT_INTEGER        0x00000001
  1153. #define HINT_STRICT_REFS    0x00000002
  1154.  
  1155. #define HINT_BLOCK_SCOPE    0x00000100
  1156. #define HINT_STRICT_SUBS    0x00000200
  1157. #define HINT_STRICT_VARS    0x00000400
  1158.  
  1159. /**************************************************************************/
  1160. /* This regexp stuff is global since it always happens within 1 expr eval */
  1161. /**************************************************************************/
  1162.  
  1163. EXT char *    regprecomp;    /* uncompiled string. */
  1164. EXT char *    regparse;    /* Input-scan pointer. */
  1165. EXT char *    regxend;    /* End of input for compile */
  1166. EXT I32        regnpar;    /* () count. */
  1167. EXT char *    regcode;    /* Code-emit pointer; ®dummy = don't. */
  1168. EXT I32        regsize;    /* Code size. */
  1169. EXT I32        regnaughty;    /* How bad is this pattern? */
  1170. EXT I32        regsawback;    /* Did we see \1, ...? */
  1171.  
  1172. EXT char *    reginput;    /* String-input pointer. */
  1173. EXT char *    regbol;        /* Beginning of input, for ^ check. */
  1174. EXT char *    regeol;        /* End of input, for $ check. */
  1175. EXT char **    regstartp;    /* Pointer to startp array. */
  1176. EXT char **    regendp;    /* Ditto for endp. */
  1177. EXT U32 *    reglastparen;    /* Similarly for lastparen. */
  1178. EXT char *    regtill;    /* How far we are required to go. */
  1179. EXT U16        regflags;    /* are we folding, multilining? */
  1180. EXT char    regprev;    /* char before regbol, \n if none */
  1181.  
  1182. /***********************************************/
  1183. /* Global only to current interpreter instance */
  1184. /***********************************************/
  1185.  
  1186. #ifdef MULTIPLICITY
  1187. #define IEXT
  1188. #define IINIT(x)
  1189. struct interpreter {
  1190. #else
  1191. #define IEXT EXT
  1192. #define IINIT(x) INIT(x)
  1193. #endif
  1194.  
  1195. /* pseudo environmental stuff */
  1196. IEXT int    Iorigargc;
  1197. IEXT char **    Iorigargv;
  1198. IEXT GV *    Ienvgv;
  1199. IEXT GV *    Isiggv;
  1200. IEXT GV *    Iincgv;
  1201. IEXT char *    Iorigfilename;
  1202. IEXT SV *    Idiehook;
  1203. IEXT SV *    Iwarnhook;
  1204. IEXT SV *    Iparsehook;
  1205.  
  1206. /* switches */
  1207. IEXT char *    Icddir;
  1208. IEXT bool    Iminus_c;
  1209. IEXT char    Ipatchlevel[6];
  1210. IEXT char *    Inrs IINIT("\n");
  1211. IEXT U32    Inrschar IINIT('\n');   /* final char of rs, or 0777 if none */
  1212. IEXT I32    Inrslen IINIT(1);
  1213. IEXT char *    Isplitstr IINIT(" ");
  1214. IEXT bool    Ipreprocess;
  1215. IEXT bool    Iminus_n;
  1216. IEXT bool    Iminus_p;
  1217. IEXT bool    Iminus_l;
  1218. IEXT bool    Iminus_a;
  1219. IEXT bool    Iminus_F;
  1220. IEXT bool    Idoswitches;
  1221. IEXT bool    Idowarn;
  1222. IEXT bool    Idoextract;
  1223. IEXT bool    Isawampersand;    /* must save all match strings */
  1224. IEXT bool    Isawstudy;    /* do fbm_instr on all strings */
  1225. IEXT bool    Isawi;        /* study must assume case insensitive */
  1226. IEXT bool    Isawvec;
  1227. IEXT bool    Iunsafe;
  1228. IEXT bool    Ido_undump;        /* -u or dump seen? */
  1229. IEXT char *    Iinplace;
  1230. IEXT char *    Ie_tmpname;
  1231. IEXT FILE *    Ie_fp;
  1232. IEXT VOL U32    Idebug;
  1233. IEXT U32    Iperldb;
  1234.     /* This value may be raised by extensions for testing purposes */
  1235. IEXT int    Iperl_destruct_level;    /* 0=none, 1=full, 2=full with checks */
  1236.  
  1237. /* magical thingies */
  1238. IEXT Time_t    Ibasetime;        /* $^T */
  1239. IEXT SV *    Iformfeed;        /* $^L */
  1240. IEXT char *    Ichopset IINIT(" \n-");    /* $: */
  1241. IEXT char *    Irs IINIT("\n");    /* $/ */
  1242. IEXT U32    Irschar IINIT('\n');    /* final char of rs, or 0777 if none */
  1243. IEXT STRLEN    Irslen IINIT(1);
  1244. IEXT bool    Irspara;
  1245. IEXT char *    Iofs;            /* $, */
  1246. IEXT STRLEN    Iofslen;
  1247. IEXT char *    Iors;            /* $\ */
  1248. IEXT STRLEN    Iorslen;
  1249. IEXT char *    Iofmt;            /* $# */
  1250. IEXT I32    Imaxsysfd IINIT(MAXSYSFD); /* top fd to pass to subprocesses */
  1251. IEXT int    Imultiline;      /* $*--do strings hold >1 line? */
  1252. IEXT U32    Istatusvalue;    /* $? */
  1253.  
  1254. IEXT struct stat Istatcache;        /* _ */
  1255. IEXT GV *    Istatgv;
  1256. IEXT SV *    Istatname IINIT(Nullsv);
  1257.  
  1258. /* shortcuts to various I/O objects */
  1259. IEXT GV *    Istdingv;
  1260. IEXT GV *    Ilast_in_gv;
  1261. IEXT GV *    Idefgv;
  1262. IEXT GV *    Iargvgv;
  1263. IEXT GV *    Idefoutgv;
  1264. IEXT GV *    Iargvoutgv;
  1265.  
  1266. /* shortcuts to regexp stuff */
  1267. IEXT GV *    Ileftgv;
  1268. IEXT GV *    Iampergv;
  1269. IEXT GV *    Irightgv;
  1270. IEXT PMOP *    Icurpm;        /* what to do \ interps from */
  1271. IEXT I32 *    Iscreamfirst;
  1272. IEXT I32 *    Iscreamnext;
  1273. IEXT I32    Imaxscream IINIT(-1);
  1274. IEXT SV *    Ilastscream;
  1275.  
  1276. /* shortcuts to debugging objects */
  1277. IEXT GV *    IDBgv;
  1278. IEXT GV *    IDBline;
  1279. IEXT GV *    IDBsub;
  1280. IEXT SV *    IDBsingle;
  1281. IEXT SV *    IDBtrace;
  1282. IEXT SV *    IDBsignal;
  1283. IEXT AV *    Ilineary;    /* lines of script for debugger */
  1284. IEXT AV *    Idbargs;    /* args to call listed by caller function */
  1285.  
  1286. /* symbol tables */
  1287. IEXT HV *    Idefstash;    /* main symbol table */
  1288. IEXT HV *    Icurstash;    /* symbol table for current package */
  1289. IEXT HV *    Idebstash;    /* symbol table for perldb package */
  1290. IEXT SV *    Icurstname;    /* name of current package */
  1291. IEXT AV *    Ibeginav;    /* names of BEGIN subroutines */
  1292. IEXT AV *    Iendav;        /* names of END subroutines */
  1293. IEXT AV *    Ipad;        /* storage for lexically scoped temporaries */
  1294. IEXT AV *    Ipadname;    /* variable names for "my" variables */
  1295.  
  1296. /* memory management */
  1297. IEXT SV **    Itmps_stack;
  1298. IEXT I32    Itmps_ix IINIT(-1);
  1299. IEXT I32    Itmps_floor IINIT(-1);
  1300. IEXT I32    Itmps_max;
  1301. IEXT I32    Isv_count;    /* how many SV* are currently allocated */
  1302. IEXT I32    Isv_objcount;    /* how many objects are currently allocated */
  1303. IEXT SV*    Isv_root;    /* storage for SVs belonging to interp */
  1304. IEXT SV*    Isv_arenaroot;    /* list of areas for garbage collection */
  1305.  
  1306. /* funky return mechanisms */
  1307. IEXT I32    Ilastspbase;
  1308. IEXT I32    Ilastsize;
  1309. IEXT int    Iforkprocess;    /* so do_open |- can return proc# */
  1310.  
  1311. /* subprocess state */
  1312. IEXT AV *    Ifdpid;        /* keep fd-to-pid mappings for my_popen */
  1313. IEXT HV *    Ipidstatus;    /* keep pid-to-status mappings for waitpid */
  1314.  
  1315. /* internal state */
  1316. IEXT VOL int    Iin_eval;    /* trap "fatal" errors? */
  1317. IEXT OP *    Irestartop;    /* Are we propagating an error from croak? */
  1318. IEXT int    Idelaymagic;    /* ($<,$>) = ... */
  1319. IEXT bool    Idirty;        /* In the middle of tearing things down? */
  1320. IEXT U8        Ilocalizing;    /* are we processing a local() list? */
  1321. IEXT bool    Itainted;    /* using variables controlled by $< */
  1322. IEXT bool    Itainting;    /* doing taint checks */
  1323.  
  1324. /* trace state */
  1325. IEXT I32    Idlevel;
  1326. IEXT I32    Idlmax IINIT(128);
  1327. IEXT char *    Idebname;
  1328. IEXT char *    Idebdelim;
  1329.  
  1330. /* current interpreter roots */
  1331. IEXT CV *    Imain_cv;
  1332. IEXT OP *    Imain_root;
  1333. IEXT OP *    Imain_start;
  1334. IEXT OP *    Ieval_root;
  1335. IEXT OP *    Ieval_start;
  1336.  
  1337. /* runtime control stuff */
  1338. IEXT COP * VOL    Icurcop IINIT(&compiling);
  1339. IEXT line_t    Icopline IINIT(NOLINE);
  1340. IEXT CONTEXT *    Icxstack;
  1341. IEXT I32    Icxstack_ix IINIT(-1);
  1342. IEXT I32    Icxstack_max IINIT(128);
  1343. IEXT jmp_buf    Itop_env;
  1344. IEXT I32    Irunlevel;
  1345.  
  1346. /* stack stuff */
  1347. IEXT AV *    Istack;        /* THE STACK */
  1348. IEXT AV *    Imainstack;    /* the stack when nothing funny is happening */
  1349. IEXT SV **    Imystack_base;    /* stack->array_ary */
  1350. IEXT SV **    Imystack_sp;    /* stack pointer now */
  1351. IEXT SV **    Imystack_max;    /* stack->array_ary + stack->array_max */
  1352.  
  1353. /* format accumulators */
  1354. IEXT SV *    Iformtarget;
  1355. IEXT SV *    Ibodytarget;
  1356. IEXT SV *    Itoptarget;
  1357.  
  1358. /* statics moved here for shared library purposes */
  1359. IEXT SV        Istrchop;    /* return value from chop */
  1360. IEXT int    Ifilemode;    /* so nextargv() can preserve mode */
  1361. IEXT int    Ilastfd;    /* what to preserve mode on */
  1362. IEXT char *    Ioldname;    /* what to preserve mode on */
  1363. IEXT char **    IArgv;        /* stuff to free from do_aexec, vfork safe */
  1364. IEXT char *    ICmd;        /* stuff to free from do_aexec, vfork safe */
  1365. IEXT OP *    Isortcop;    /* user defined sort routine */
  1366. IEXT HV *    Isortstash;    /* which is in some package or other */
  1367. IEXT GV *    Ifirstgv;    /* $a */
  1368. IEXT GV *    Isecondgv;    /* $b */
  1369. IEXT AV *    Isortstack;    /* temp stack during pp_sort() */
  1370. IEXT AV *    Isignalstack;    /* temp stack during sighandler() */
  1371. IEXT SV *    Imystrk;    /* temp key string for do_each() */
  1372. IEXT I32    Idumplvl;    /* indentation level on syntax tree dump */
  1373. IEXT PMOP *    Ioldlastpm;    /* for saving regexp context during debugger */
  1374. IEXT I32    Igensym;    /* next symbol for getsym() to define */
  1375. IEXT bool    Ipreambled;
  1376. IEXT int    Ilaststatval IINIT(-1);
  1377. IEXT I32    Ilaststype IINIT(OP_STAT);
  1378.  
  1379. #undef IEXT
  1380. #undef IINIT
  1381.  
  1382. #ifdef MULTIPLICITY
  1383. };
  1384. #else
  1385. struct interpreter {
  1386.     char broiled;
  1387. };
  1388. #endif
  1389.  
  1390. #include "pp.h"
  1391.  
  1392. #ifdef __cplusplus
  1393. extern "C" {
  1394. #endif
  1395.  
  1396. #ifdef __cplusplus
  1397. #  ifndef I_STDARG
  1398. #    define I_STDARG 1
  1399. #  endif
  1400. #endif
  1401.  
  1402. #ifdef I_STDARG
  1403. #  include <stdarg.h>
  1404. #else
  1405. #  ifdef I_VARARGS
  1406. #    include <varargs.h>
  1407. #  endif
  1408. #endif
  1409.  
  1410. #include "proto.h"
  1411.  
  1412. #ifdef EMBED
  1413. #define Perl_sv_setptrobj(rv,ptr,name) Perl_sv_setref_iv(rv,name,(IV)ptr)
  1414. #define Perl_sv_setptrref(rv,ptr) Perl_sv_setref_iv(rv,Nullch,(IV)ptr)
  1415. #else
  1416. #define sv_setptrobj(rv,ptr,name) sv_setref_iv(rv,name,(IV)ptr)
  1417. #define sv_setptrref(rv,ptr) sv_setref_iv(rv,Nullch,(IV)ptr)
  1418. #endif
  1419.  
  1420. #ifdef __cplusplus
  1421. };
  1422. #endif
  1423.  
  1424. /* The following must follow proto.h */
  1425.  
  1426. #ifdef DOINIT
  1427. MGVTBL vtbl_sv =    {magic_get,
  1428.                 magic_set,
  1429.                     magic_len,
  1430.                         0,    0};
  1431. MGVTBL vtbl_env =    {0,    0,    0,    0,    0};
  1432. MGVTBL vtbl_envelem =    {0,    magic_setenv,
  1433.                     0,    magic_clearenv,
  1434.                             0};
  1435. MGVTBL vtbl_sig =    {0,    0,         0, 0, 0};
  1436. MGVTBL vtbl_sigelem =    {0,    magic_setsig,
  1437.                     0,    0,    0};
  1438. MGVTBL vtbl_pack =    {0,    0,    0,    magic_wipepack,
  1439.                             0};
  1440. MGVTBL vtbl_packelem =    {magic_getpack,
  1441.                 magic_setpack,
  1442.                     0,    magic_clearpack,
  1443.                             0};
  1444. MGVTBL vtbl_dbline =    {0,    magic_setdbline,
  1445.                     0,    0,    0};
  1446. MGVTBL vtbl_isa =    {0,    magic_setisa,
  1447.                     0,    0,    0};
  1448. MGVTBL vtbl_isaelem =    {0,    magic_setisa,
  1449.                     0,    0,    0};
  1450. MGVTBL vtbl_arylen =    {magic_getarylen,
  1451.                 magic_setarylen,
  1452.                     0,    0,    0};
  1453. MGVTBL vtbl_glob =    {magic_getglob,
  1454.                 magic_setglob,
  1455.                     0,    0,    0};
  1456. MGVTBL vtbl_mglob =    {0,    magic_setmglob,
  1457.                     0,    0,    0};
  1458. MGVTBL vtbl_taint =    {magic_gettaint,magic_settaint,
  1459.                     0,    0,    0};
  1460. MGVTBL vtbl_substr =    {0,    magic_setsubstr,
  1461.                     0,    0,    0};
  1462. MGVTBL vtbl_vec =    {0,    magic_setvec,
  1463.                     0,    0,    0};
  1464. MGVTBL vtbl_pos =    {magic_getpos,
  1465.                 magic_setpos,
  1466.                     0,    0,    0};
  1467. MGVTBL vtbl_bm =    {0,    magic_setbm,
  1468.                     0,    0,    0};
  1469. MGVTBL vtbl_uvar =    {magic_getuvar,
  1470.                 magic_setuvar,
  1471.                     0,    0,    0};
  1472.  
  1473. #ifdef OVERLOAD
  1474. MGVTBL vtbl_amagic =       {0,     magic_setamagic,
  1475.                                         0,      0,      magic_setamagic};
  1476. MGVTBL vtbl_amagicelem =   {0,     magic_setamagic,
  1477.                                         0,      0,      magic_setamagic};
  1478. #endif /* OVERLOAD */
  1479.  
  1480. #else
  1481. EXT MGVTBL vtbl_sv;
  1482. EXT MGVTBL vtbl_env;
  1483. EXT MGVTBL vtbl_envelem;
  1484. EXT MGVTBL vtbl_sig;
  1485. EXT MGVTBL vtbl_sigelem;
  1486. EXT MGVTBL vtbl_pack;
  1487. EXT MGVTBL vtbl_packelem;
  1488. EXT MGVTBL vtbl_dbline;
  1489. EXT MGVTBL vtbl_isa;
  1490. EXT MGVTBL vtbl_isaelem;
  1491. EXT MGVTBL vtbl_arylen;
  1492. EXT MGVTBL vtbl_glob;
  1493. EXT MGVTBL vtbl_mglob;
  1494. EXT MGVTBL vtbl_taint;
  1495. EXT MGVTBL vtbl_substr;
  1496. EXT MGVTBL vtbl_vec;
  1497. EXT MGVTBL vtbl_pos;
  1498. EXT MGVTBL vtbl_bm;
  1499. EXT MGVTBL vtbl_uvar;
  1500.  
  1501. #ifdef OVERLOAD
  1502. EXT MGVTBL vtbl_amagic;
  1503. EXT MGVTBL vtbl_amagicelem;
  1504. #endif /* OVERLOAD */
  1505.  
  1506. #endif
  1507.  
  1508. #ifdef OVERLOAD
  1509. EXT long amagic_generation;
  1510.  
  1511. #define NofAMmeth 29
  1512. #ifdef DOINIT
  1513. EXT char * AMG_names[NofAMmeth][2] = {
  1514.   {"fallback","abs"},
  1515.   {"bool", "nomethod"},
  1516.   {"\"\"", "0+"},
  1517.   {"+","+="},
  1518.   {"-","-="},
  1519.   {"*", "*="},
  1520.   {"/", "/="},
  1521.   {"%", "%="},
  1522.   {"**", "**="},
  1523.   {"<<", "<<="},
  1524.   {">>", ">>="},
  1525.   {"&", "&="},
  1526.   {"|", "|="},
  1527.   {"^", "^="},
  1528.   {"<", "<="},
  1529.   {">", ">="},
  1530.   {"==", "!="},
  1531.   {"<=>", "cmp"},
  1532.   {"lt", "le"},
  1533.   {"gt", "ge"},
  1534.   {"eq", "ne"},
  1535.   {"!", "~"},
  1536.   {"++", "--"},
  1537.   {"atan2", "cos"},
  1538.   {"sin", "exp"},
  1539.   {"log", "sqrt"},
  1540.   {"x","x="},
  1541.   {".",".="},
  1542.   {"=","neg"}
  1543. };
  1544. #else
  1545. EXT char * AMG_names[NofAMmeth][2];
  1546. #endif /* def INITAMAGIC */
  1547.  
  1548. struct  am_table        {
  1549.   long was_ok_sub;
  1550.   long was_ok_am;
  1551.   CV* table[NofAMmeth*2];
  1552.   long fallback;
  1553. };
  1554. typedef struct am_table AMT;
  1555.  
  1556. #define AMGfallNEVER    1
  1557. #define AMGfallNO    2
  1558. #define AMGfallYES    3
  1559.  
  1560. enum {
  1561.   fallback_amg,    abs_amg,
  1562.   bool__amg,    nomethod_amg,
  1563.   string_amg,    numer_amg,
  1564.   add_amg,    add_ass_amg,
  1565.   subtr_amg,    subtr_ass_amg,
  1566.   mult_amg,    mult_ass_amg,
  1567.   div_amg,    div_ass_amg,
  1568.   mod_amg,    mod_ass_amg,
  1569.   pow_amg,    pow_ass_amg,
  1570.   lshift_amg,    lshift_ass_amg,
  1571.   rshift_amg,    rshift_ass_amg,
  1572.   band_amg,    band_ass_amg,
  1573.   bor_amg,    bor_ass_amg,
  1574.   bxor_amg,    bxor_ass_amg,
  1575.   lt_amg,    le_amg,
  1576.   gt_amg,    ge_amg,
  1577.   eq_amg,    ne_amg,
  1578.   ncmp_amg,    scmp_amg,
  1579.   slt_amg,    sle_amg,
  1580.   sgt_amg,    sge_amg,
  1581.   seq_amg,    sne_amg,
  1582.   not_amg,    compl_amg,
  1583.   inc_amg,    dec_amg,
  1584.   atan2_amg,    cos_amg,
  1585.   sin_amg,    exp_amg,
  1586.   log_amg,    sqrt_amg,
  1587.   repeat_amg,   repeat_ass_amg,
  1588.   concat_amg,    concat_ass_amg,
  1589.   copy_amg,    neg_amg
  1590. };
  1591. #endif /* OVERLOAD */
  1592.  
  1593. #endif /* Include guard */
  1594.